package com;

import com.fz.entity.Book;
import com.fz.entity.Teacher;
import com.fz.entity.User;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by webrx on 2017-09-08.
 */
public class Demo {
    @Test
    public void tt(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        User u = ctx.getBean(User.class);
        System.out.println(u);
        u.save();
        u.saveBook();
        u.addUser();
        ctx.close();
    }

    @Test
    public void t(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        //User u1 = ctx.getBean(User.class);
        //User u2 = ctx.getBean(User.class);

        //Teacher t = ctx.getBean("teacher",Teacher.class);
        //Teacher t = ctx.getBean("tt",Teacher.class);
        //System.out.println(t.getId());
        //System.out.println(t.getBook().getName());

        Book b = ctx.getBean("book",Book.class);
        System.out.println(b.getTeacher());
        //User u = ctx.getBean(User.class);
        //System.out.println(b);
        ctx.close();

    }
}
